<!--<?php print <<<EOT
-->
<div id="breadCrumb">
		<img src="$imgpath/$stylepath/thread/home-old.gif" align="absmiddle" />&nbsp;<a href="$db_bfn" title="$db_bbsname">$db_bbsname</a> &raquo; <a href="$basename">medal center</a>
</div>
<div class="t3" style="margin-top:8px">
<table width="100%" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="22%" valign="top">
<div class="t">
<table width="100%" cellspacing="0" cellpadding="0" align="center">
	<tr>
		<td class="h">
			operation
		</td>
	</tr>
	<tr class="tr3">
		<td>
			<a href="$basename">introduction to medal</a>
		</td>
	</tr>
<!--
EOT;
if($md_ifapply && strpos($md_appgroups,",$groupid,")!==false){print <<<EOT
-->
	<tr class="tr3">
		<td>
			<a href="$basename&action=apply">apply for a medal</a>
		</td>
	</tr>
<!--
EOT;
}print <<<EOT
-->
	<tr class="tr3">
		<td>
			<a href="$basename&action=list">the list of obtaining medals</a>
		</td>
	</tr>
	<tr class="tr3">
		<td>
			<a href="$basename&action=log">situation for awarding a medal</a>
		</td>
	</tr>

<!--
EOT;
if(strpos($md_groups,",$groupid,")!==false){print <<<EOT
-->
	<tr class="tr3">
		<td>
			<a href="$basename&action=award">award a medal</a>
		</td>
	</tr>
<!--
EOT;
}print <<<EOT
-->
<!--
EOT;
if($md_ifapply && strpos($md_groups,",$groupid,")!==false){print <<<EOT
-->
	<tr class="tr3">
		<td>
			<a href="$basename&action=approve">application examination</a>
		</td>
	</tr>
<!--
EOT;
}print <<<EOT
-->
</table>
</div>
<div class="t" style="width:98%;margin-right:0">
<table width="100%" cellpadding="0" cellspacing="0">
	<tr>
		<td class="h">the medals you obtained</td>
	</tr>
	<tr class="tr1">
		<th style="text-align:center">
			$userface<br /><br />
<!--
EOT;
if($userdb['medals']){
foreach($userdb['medals'] as $key=>$value){
if($_MEDALDB[$value][picurl]){print <<<EOT
-->
			<img src="$hkimg/{$_MEDALDB[$value][picurl]}" title="{$_MEDALDB[$value][name]}"/> 
<!--
EOT;
}}}else{print <<<EOT
-->
			<br/>you have no medal yet
<!--
EOT;
}print <<<EOT
-->
		</th>
	</tr>
</table>
</div>
</td>
<td valign="top">

<!--
EOT;
if(!$action){print <<<EOT
-->
<div class="t" style="width:98%;margin-right:0">
<table width="100%" cellspacing="0" cellpadding="0" align="center">
	<tr><td class="h" colspan="4">introduction to medal</td></tr>
	<tr class="tr2 tac">
		<td width="5%">ID</td>
		<td width="15%">name of medal</td>
		<td width="*">explanation of medal</td>
		<td width="15%">picture of medal</td>
	</tr>
<!--
EOT;
$num=0;
foreach($_MEDALDB as $key => $value){
if($md_ifapply && strpos($md_appgroups,",$groupid,")!==false && !in_array($key,$userdb['medals'])){
	$value[name] = "<a href=\"$basename&action=apply&id=$value[id]\" title=\"apply for the medal\">".$value[name]."</a>";
}
$num++;
print <<<EOT
-->
	<tr class="tr3 tr tac">
		<td>$num</td>
		<td>$value[name]</td>
		<th>$value[intro]</th>
		<td><img src="$hkimg/$value[picurl]" /></td>
	</tr>
<!--
EOT;
}print <<<EOT
-->
</table></div>
<!--
EOT;
}elseif($action=='list'){print <<<EOT
-->
<div class="t" style="width:98%;margin-right:0">
<table width="100%" cellspacing="0" cellpadding="0" align="center">
	<tr><td class="h" colspan="4">the list of obtaining medals</td></tr>
	<tr class="tr2 tac">
		<td width="5%">ID</td>
		<td>username</td>
		<td>achieved medals</td>
	</tr>
<!--
EOT;
$num=($page-1)*$db_perpage;
foreach($listdb as $key=>$value){
$num++;
print <<<EOT
-->
	<tr class="tr3 tr tac">
		<td>$num</td>
		<td><a href="u.php?action=show&uid=$value[uid]" target="_blank">$value[username]</a></td>
		<td>$value[medals]</td>
	</tr>
<!--
EOT;
}print <<<EOT
-->
</table></div>
<div class="t" style="width:98%;margin-right:0;border:none;">
	$pages
</div>
<!--
EOT;
}elseif($action=='award'){print <<<EOT
-->
<form method="post" action="$basename&action=award&">
<input type="hidden" name="step" value="2" />
<div class="t" style="width:98%;margin-right:0">
<table width="100%" cellspacing="0" cellpadding="0" align="center">
	<tr><td class="h" colspan="4">award a medal</td></tr>
	<tr class="tr3 tr">
		<td style="text-align:right" width="30%">username: </td>
		<th><input class="input" type="text" name="pwuser" size="40" value="$pwuser"/>(multiple users can use","to separate)</th>
	</tr>
	<tr class="tr3 tr">
		<td style="text-align:right">select operation: </td>
		<th>
			<input type="radio" name="type" value="1" $type_1 /> award
			<input type="radio" name="type" value="2" $type_2/> retake
		</th>
	</tr>
	<tr class="tr3 tr">
		<td style="text-align:right">select medal: </td>
		<th>
			<select name="medal">
				<option>select medal</option>
<!--
EOT;
foreach($_MEDALDB as $key=>$value){
if($medal){
	$selected = $medal==$key ? "selected=\"selected\"":"";
}else{
	$selected = "";
}
print <<<EOT
-->
				<option value="$key" $selected>$value[name]</option>
<!--
EOT;
}print <<<EOT
-->
			</select>
		</th>
	</tr>
	<tr class="tr3 tr">
		<td style="text-align:right">period of validity:</td>
		<th>
			<select name="timelimit">
				<option value="0">forever</option>
				<option value="1">one month</option>
				<option value="3">three months</option>
				<option value="6">six months</option>
				<option value="12">one year</option>
			</select>
		</th>
	</tr>
	<tr class="tr3 tr">
		<td style="text-align:right">reason for operation: </td>
		<th><input class="input" type="text" name="reason" size="50" /></th>
	</tr>
</table></div>
<div style="text-align:center;margin-bottom:25px"><input class="btn" type="submit" value="submit" /></div>
</form>
<!--
EOT;
}elseif($action=='log'){print <<<EOT
-->
<div class="t" style="width:98%;margin-right:0">
<table width="100%" cellspacing="0" cellpadding="0" align="center">
	<tr><td class="h" colspan="9">situation for awarding a medal</td></tr>
	<tr class="tr2 tac">
		<td width="5%">ID</td>
		<td width="12%">username</td>
		<td width="12%">administrator</td>
		<td width="10%">name of medal</td>
		<td width="7%">operation</td>
		<td><div style="table-layout:fixed;word-wrap:break-word;">renson for operation</div></td>
		<td width="15%">time for operation</td>
		<td width="7%">period of validity</td>
<!--
EOT;
if($groupid==3){print <<<EOT
-->
		<td width="6%">delete</td>
<!--
EOT;
}print <<<EOT
-->
	</tr>
<!--
EOT;
$num=($page-1)*$db_perpage;
foreach($logdb as $key=>$value){
$num++;
print <<<EOT
-->
	<tr class="tr3 tac">
		<td>$num</td>
		<td>$value[awardee]</td>
		<td>$value[awarder]</td>
		<td>{$_MEDALDB[$value[level]][name]}<br /></td>
<!--
EOT;
if($value[action]==1){print <<<EOT
-->
		<td>award</td>
<!--
EOT;
}elseif($value[action]==2){print <<<EOT
-->
		<td>retake</td>
<!--
EOT;
}print <<<EOT
-->
		<td>$value[why]<br /></td>
		<td>$value[awardtime]</td>
<!--
EOT;
if($value[action]==1){
if($value[timelimit]<1){print <<<EOT
-->
		<td>forever</td>
<!--
EOT;
}else{print <<<EOT
-->
		<td>$value[timelimit] month</td>
<!--
EOT;
}}else{ print <<<EOT
-->
		<td>--</td>
<!--
EOT;
}if($groupid==3){
if($value['action']==1 && $value['state']==0 && $value['timelimit']>0){print <<<EOT
-->
		<td>--</td>
<!--
EOT;
}else{ print <<<EOT
-->
		<td><a href="$basename&action=log&job=del&id=$value[id]">delete</a></td>
<!--
EOT;
}}print <<<EOT
-->
	</tr>
<!--
EOT;
}print <<<EOT
-->
</table></div>
<div class="t" style="width:98%;margin-right:0;border:none;">
	$pages
</div>
<!--
EOT;
}elseif($action=='apply'){
print <<<EOT
-->
<form method="post" action="$basename&action=apply&">
<input type="hidden" name="step" value="2" />
<div class="t" style="width:98%;margin-right:0">
<table width="100%" cellspacing="0" cellpadding="0" align="center">
	<tr><td class="h" colspan="4">apply for a medal</td></tr>
	<tr class="tr3 tr">
		<td style="text-align:right" width="30%">select medal: </td>
		<th>
			<select name="medal">
				<option>select medal</option>
<!--
EOT;
foreach($_MEDALDB as $key=>$value){
$selected = $key==$id ? "selected='selected'":'';
print <<<EOT
-->
				<option value="$key" $selected>$value[name]</option>
<!--
EOT;
}print <<<EOT
-->
			</select>
		</th>
	</tr>
	<tr class="tr3 tr">
		<td style="text-align:right">period of validity:</td>
		<th>
			<select name="timelimit">
				<option value="0">forever</option>
				<option value="1">one month</option>
				<option value="3">three months</option>
				<option value="6">six months</option>
				<option value="12">one year</option>
			</select>
		</th>
	</tr>
	<tr class="tr3 tr">
		<td style="text-align:right">renson for application: </td>
		<th><input class="input" type="text" name="reason" size="50" /></th>
	</tr>
</table></div>
<div style="text-align:center;margin-bottom:25px"><input class="btn" type="submit" value="submit" /></div>
</form>
<!--
EOT;
}elseif($action=='approve'){
print <<<EOT
-->
<form action="$basename&action=approve&" method="post">
<div class="t" style="width:98%;margin-right:0">
<table width="100%" cellspacing="0" cellpadding="0" align="center">
	<tr><td class="h" colspan="8">the list of applying for medals</td></tr>
	<tr class="tr2 tac">
		<td width="5%">select</td>
		<td width="5%">ID</td>
		<td width="12%">username</td>
		<td width="10%">name of medal</td>
		<td><div style="table-layout:fixed;word-wrap:break-word;">renson for operation</div></td>
		<td width="15%">time for application</td>
		<td width="7%">period of validity</td>
		<td width="10%">operation</td>
	</tr>
<!--
EOT;
$num=($page-1)*$db_perpage;
foreach($appdb as $key=>$value){
$value[awardee1]=urlencode($value[awardee]);
$num++;
print <<<EOT
-->
	<tr class="tr3 tac">
		<td><input name="id[]" value="$value[id]" type="checkbox"></td>
		<td>$num</td>
		<td><a href="u.php?action=show&username=$value[awardee]" target="_blank" >$value[awardee]</a></td>
		<td>{$_MEDALDB[$value[level]][name]}<br /></td>
		<td>$value[why]<br /></td>
		<td>$value[awardtime]</td>
<!--
EOT;
if($value[timelimit]<1){print <<<EOT
-->
		<td>forever</td>
<!--
EOT;
}else{print <<<EOT
-->
		<td>$value[timelimit] month</td>
<!--
EOT;
}print <<<EOT
-->
		<td><a href="$basename&action=approve&job=del&id=$value[id]">delete</a>|<a href="$basename&action=approve&job=pass&id=$value[id]">pass</a></td>
	</tr>
<!--
EOT;
}print <<<EOT
-->
</table>
</div>
<center>
	<input class="btn" name="chkall" value="all selected" onclick="CheckAll(this.form)" type="button">
	<input class="btn" value="submit" type="submit">
	<input name="job" value="pass" type="radio">pass
	<input name="job" value="del" checked="checked" type="radio">delete
</center>
</form>
<div class="t" style="width:98%;margin-right:0;border:none;">
	$pages
</div>
<script language="JavaScript">
ifcheck = true;
function CheckAll(form){
	for(var i=0;i<form.elements.length-2;i++){
		var e = form.elements[i];
		if(e.type=='checkbox' && e.name!='ifsave') e.checked = ifcheck;
	}
	ifcheck = ifcheck == true ? false : true;
}

</script>
<!--
EOT;
}print <<<EOT
-->
</td>
</tr>
</table></div>
<!--
EOT;
?>-->